﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml;
using System.Collections.Generic;

namespace aucn.web.au
{
    public partial class UndergradList : System.Web.UI.UserControl
    {
        string cssClass = string.Empty;
        public string CssClass
        {
            get { return this.cssClass; }
            set { this.cssClass = value; panel1.CssClass = value; }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            // Load departments
            
            XmlDocument doc = new XmlDocument();
            List<Department> deptList = new List<Department>();
            
            try
            {
                doc.Load(Server.MapPath("~/App_Data/subjects.xml"));
                XmlNamespaceManager xm = new XmlNamespaceManager(doc.NameTable);
                xm.AddNamespace("x", "http://tempuri.org/subject.xsd");
                XmlNodeList nodeList = doc.DocumentElement.SelectNodes("x:department", xm);
                foreach (XmlNode node in nodeList)
                {
                    Department d = new Department(node.Attributes["name"].Value, node.SelectSingleNode("x:name", xm).InnerText, node.SelectSingleNode("x:chname", xm).InnerText, "", "", "", null);
                    deptList.Add(d);
                }

                Repeater1.DataSource = deptList;
                Repeater1.DataBind();
                //Cache["DEPTLIST"] = html.ToString();
                //ltrDepts.Text = (string)Cache["DEPTLIST"];
            }
            catch
            {
            }
        }
    }
}